home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16_Src.lha / Python16_Source / Include / frameobject.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-03  |  2.7 KB  |  89 lines

  1. #ifndef Py_FRAMEOBJECT_H
  2. #define Py_FRAMEOBJECT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. /* Frame object interface */
  8.  
  9. typedef struct {
  10.     int b_type;        /* what kind of block this is */
  11.     int b_handler;        /* where to jump to find handler */
  12.     int b_level;        /* value stack level to pop to */
  13. } PyTryBlock;
  14.  
  15. typedef struct _frame {
  16.     PyObject_HEAD
  17.     struct _frame *f_back;    /* previous frame, or NULL */
  18.     PyCodeObject *f_code;    /* code segment */
  19.     PyObject *f_builtins;    /* builtin symbol table (PyDictObject) */
  20.     PyObject *f_globals;    /* global symbol table (PyDictObject) */
  21.     PyObject *f_locals;    /* local symbol table (PyDictObject) */
  22.     PyObject **f_valuestack; /* points after the last local */
  23.     PyObject *f_trace;    /* Trace function */
  24.     PyObject *f_exc_type, *f_exc_value, *f_exc_traceback;
  25.     PyThreadState *f_tstate;
  26.     int f_lasti;        /* Last instruction if called */
  27.     int f_lineno;        /* Current line number */
  28.     int f_restricted;    /* Flag set if restricted operations
  29.                    in this scope */
  30.     int f_iblock;        /* index in f_blockstack */
  31.     PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */
  32.     int f_nlocals;        /* number of locals */
  33.     int f_stacksize;    /* size of value stack */
  34.     PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */
  35. } PyFrameObject;
  36.  
  37.  
  38. /* Standard object interface */
  39.  
  40. extern DL_IMPORT(PyTypeObject) PyFrame_Type;
  41.  
  42. #define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type)
  43.  
  44. DL_IMPORT(PyFrameObject *) PyFrame_New
  45.     Py_PROTO((PyThreadState *, PyCodeObject *,
  46.           PyObject *, PyObject *));
  47.  
  48.  
  49. /* The rest of the interface is specific for frame objects */
  50.  
  51. /* Tuple access macros */
  52.  
  53. #ifndef Py_DEBUG
  54. #define GETITEM(v, i) PyTuple_GET_ITEM((PyTupleObject *)(v), (i))
  55. #define GETITEMNAME(v, i) \
  56.     PyString_AS_STRING((PyStringObject *)GETITEM((v), (i)))
  57. #else
  58. #define GETITEM(v, i) PyTuple_GetItem((v), (i))
  59. #define GETITEMNAME(v, i) PyString_AsString(GETITEM(v, i))
  60. #endif
  61.  
  62. #define GETUSTRINGVALUE(s) ((unsigned char *)PyString_AS_STRING(s))
  63.  
  64. /* Code access macros */
  65.  
  66. #define Getconst(f, i)    (GETITEM((f)->f_code->co_consts, (i)))
  67. #define Getname(f, i)    (GETITEMNAME((f)->f_code->co_names, (i)))
  68. #define Getnamev(f, i)    (GETITEM((f)->f_code->co_names, (i)))
  69.  
  70.  
  71. /* Block management functions */
  72.  
  73. DL_IMPORT(void) PyFrame_BlockSetup Py_PROTO((PyFrameObject *, int, int, int));
  74. DL_IMPORT(PyTryBlock *) PyFrame_BlockPop Py_PROTO((PyFrameObject *));
  75.  
  76. /* Extend the value stack */
  77.  
  78. DL_IMPORT(PyObject **) PyFrame_ExtendStack Py_PROTO((PyFrameObject *, int, int));
  79.  
  80. /* Conversions between "fast locals" and locals in dictionary */
  81.  
  82. DL_IMPORT(void) PyFrame_LocalsToFast Py_PROTO((PyFrameObject *, int));
  83. DL_IMPORT(void) PyFrame_FastToLocals Py_PROTO((PyFrameObject *));
  84.  
  85. #ifdef __cplusplus
  86. }
  87. #endif
  88. #endif /* !Py_FRAMEOBJECT_H */
  89.